package cct.gaussian;

import java.util.ArrayList;
import java.util.List;

import cct.interfaces.MoleculeInterface;
import cct.interfaces.MoleculeSelectorInterface;

/**
 * <p>Title: Jamberoo - Computational Chemistry Toolkit</p>
 *
 * <p>Description: Collection of Computational Chemistry related code</p>
 *
 * <p>Copyright: Copyright (c) 2005-2009 Dr. Vladislav Vasilyev</p>
 *
 * <p>Company: The Australian National University</p>
 *
 * @author Dr. Vladislav Vasilyev
 * @version 1.0
 */
public class GaussianJob
    extends ArrayList<GaussianStep>
    implements MoleculeSelectorInterface {

  public GaussianJob() {
  }

  public int countSteps() {
    return this.size();
  }

  public GaussianStep getStep(int n) {
    if (countSteps() < 1) {
      return null;
    }
    if (n < 0) {
      System.err.println("Warning: GaussianStep: n < 0: 0 index was used...");
      return this.get(0);
    }
    else if (n >= countSteps()) {
      System.err.println("Warning: GaussianStep: n >= countSteps(): the last index was used...");
      return this.get(countSteps() - 1);
    }
    return this.get(n);
  }

  public void addStep(GaussianStep step) {
    this.add(step);
  }

  @Override
  public MoleculeInterface getMolecule(int n) {
    GaussianStep step = getStep(n);
    if (step == null) {
      return null;
    }
    return step.getMolecule();
  }

  public List getGeometries(int n) {
    GaussianStep step = getStep(n);
    if (step == null) {
      return null;
    }
    return step.getGeometries();
  }

  @Override
  public int countMolecules() {
    return this.size();
  }

  @Override
  public String getMoleculeDescription(int n) throws Exception {
    GaussianStep step = getStep(n);
    return step.getDescription();
  }

}
